﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true"
    CodeBehind="LoadOrder_old.aspx.cs" Inherits="iMall.AtoZ.GroupOn.LoadOrder" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    <link rel="stylesheet" href="/Scripts/plupload/js/jquery.plupload.queue/css/jquery.plupload.queue.css"
        type="text/css" media="screen" />
    <script type="text/javascript" src="/Scripts/plupload/js/jquery.plupload.queue/jquery.plupload.queue.js"></script>
    <script type="text/javascript" src="/Scripts/plupload/js/plupload.js"></script>
    <script type="text/javascript" src="/Scripts/plupload/js/plupload.flash.js"></script>
    <script type="text/javascript" src="/Scripts/zclip/jquery.zclip.min.js"></script>
    <script type="text/javascript" src="/Scripts/plupload/js/jquery.ui.plupload/jquery.ui.plupload.js"></script>
    <script type="text/javascript" src="/Scripts/plupload/js/i18n/cn.js"></script>
    <script type="text/javascript">
        function newGuid() {
            var guid = "";
            for (var i = 1; i <= 32; i++) {
                var n = Math.floor(Math.random() * 16.0).toString(16);
                guid += n;
                if ((i == 8) || (i == 12) || (i == 16) || (i == 20))
                    guid += "-";
            }
            return guid;
        }

        function getCurrentDirectory() {
            var locHref = location.href;
            var locArray = locHref.split("/");
            delete locArray[locArray.length - 1];
            var dirTxt = locArray.join("/");
            return dirTxt;
        }

        var bn = newGuid();
        function loadplupload() {
            // 初始化Flash上传插件
            $("#flash_uploader").pluploadQueue({
                runtimes: 'flash', 	//使用Flash插件
                url: '/Scripts/plupload/upload.aspx', 	//服务器端响应页面
                max_file_size: '1000mb', //最大文件限制
                chunk_size: '1mb', 	//一次上传数据大小
                unique_names: false, 	//是否自动生成唯一名称
                filters: [				//文件类型限制
				{title: "Excel（xls,xlsx)", extensions: "xls,xlsx" }
			],
                // 缩放图片
                //resize: { width: 320, height: 240, quality: 80 },

                // SWF文件位置
                flash_swf_url: '/Scripts/plupload/js/plupload.flash.swf',

                init: {
                    FileUploaded: function (up, file, info) {
                        var Merchant = $("#Merchant").find("option:selected").text();
                        var fileInfo = '{"name":"' + file.name + '","path":"' + info.response + '","size":"' + file.size + '","Merchant":"' + Merchant + '","batchNum":"' + bn + '"}';
                        var bii = newGuid();
                        ImpAccessData(bii, file.name);
                        SaveData(fileInfo, bii);
                        if (up.total.queued == 0) {
                            //alert('所有文件上传成功');
                        }
                    },

                    Error: function (up, args) {
                        //发生错误
                        if (args.file) {
                            alert('[出错啦] 文件:' + args.file);
                        } else {
                            alert('[出错啦]' + args);
                        }
                    }
                }
            });
        }

        function SaveData(data, id) {
            var fileInfo = 'data=' + data;
            var mi = $("#Merchant").val();
            $.ajax({
                type: "POST",
                url: "/DoPost/DoSaveOrder.ashx", //LoadOrder.aspx
                datatype: "json", //请求页面返回的数据类型  
                data: fileInfo,
                //contentType: "application/json", //注意请求页面的contentType
                beforeSend: function (XMLHttpRequest) {
                    //do beforeSend
                },
                success: function (data, status) {
                    //var dataObj = eval("(" + data + ")")
                    LoadOrderResult(data, id);
                },
                complete: function (XMLHttpRequest, status) {
                    //do complete
                },
                error: function (XMLHttpRequest, status, errorThrown) {
                    alert(errorThrown);
                }
            });
        }

        function LoadOrderResult(data, name) {
            $("#" + name).append(data);
        }

        function ImpAccessData(id, path) {
            $("#result").append("<tr id=\"" + id + "\"><td>" + path + '</td><td>已上传</td></tr>');
        }

        $(document).ready(function () {
            loadplupload();
            loadMerchant();
        });

        function loadMerchant() {
            $.ajax({
                type: '"/DoPost/DoPost.aspx?t=1',
                url: postURL + para, //postURL + para
                //contentType: "application/json",
                datatype: "text", //请求页面返回的数据类型  
                data: {},
                beforeSend: function (XMLHttpRequest) {
                    //do beforeSend
                },
                success: function (data, status) {
                    var mydata = eval("(" + data + ")");
                    debugger;
                },
                complete: function (XMLHttpRequest, status) {
                    //do complete
                },
                error: function (XMLHttpRequest, status, errorThrown) {
                    alert("【Error】" + errorThrown);
                }
            });
        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <div>
        <select id="Merchant">
            <option value="1" selected="selected">麦兜</option>
            <option value="2">olquan</option>
            <option value="3">满座</option>
            <option value="4">团好网</option>
        </select>
        <div id="flash_uploader" style="width: 460px; height: 320px;">
            您没有安装Flash！</div>
        <div>
            <table id="result" style="border: 2px; border-color: Black">
                <tr>
                    <td>
                        文件
                    </td>
                    <td>
                        上传状态
                    </td>
                    <td>
                        导入状态
                    </td>
                    <td>
                        导入结果
                    </td>
                </tr>
            </table>
        </div>
    </div>
</asp:Content>
